home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Sources / TextUtil.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  3.0 KB  |  121 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                            TextUtil.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Author:                        Anthone Burbidge
  7. //    Creation Date:        3/28/94
  8. //
  9. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef _TEXTUTIL_
  14. #include "TextUtil.h"
  15. #endif
  16.  
  17. #ifndef _TEXTFACET_
  18. #include "TextFacet.h"
  19. #endif
  20.  
  21. #ifndef _TEXTFRAME_
  22. #include "TextFrame.h"
  23. #endif
  24.  
  25. #ifndef _TEXTPART_
  26. #include "TextPart.h"
  27. #endif
  28.  
  29. #ifndef _ODTEXT_
  30. #include "ODText.h"
  31. #endif
  32.  
  33. #ifndef FWRECT_H
  34. #include "FWRect.h"
  35. #endif
  36.  
  37. // ----- Textension Includes -----
  38.  
  39. #ifndef _TextensionCommon_
  40. #include "TextensionCommon.h"
  41. #endif
  42.  
  43. #ifndef _Textension_
  44. #include "Textension.h"
  45. #endif
  46.  
  47. // ----- OpenDoc Includes -----
  48.  
  49. #ifndef _WINDOW_
  50. #include "Window.h"
  51. #endif
  52.  
  53. // ----- Macintosh Includes -----
  54.  
  55. #ifndef __FIXMATH__
  56. #include <FixMath.h>
  57. #endif
  58.  
  59. #ifndef mathRoutinesIncludes
  60. #include <Math Routines.h>
  61. #endif
  62.  
  63. #pragma segment TextPartSegment
  64.  
  65.  
  66. //===================================================================================================
  67. // CLASS CTextDrawInitiator
  68. //===================================================================================================
  69.  
  70. //---------------------------------------------------------------------------------------------------
  71. // CTextDrawInitiator::CTextDrawInitiator
  72. //---------------------------------------------------------------------------------------------------
  73.  
  74. CTextDrawInitiator::CTextDrawInitiator(CTextFacet *facet, XMPShape* clipShape) :
  75.     FW_CGraphicContext(facet->GetXMPFacet(), clipShape)
  76. {
  77.     CTextFrame *frame = (CTextFrame *) facet->GetFrame();
  78.     CTextPart *part = (CTextPart *) frame->GetPart();
  79.     
  80.     CTextension* textEdit = part->GetEditText();
  81.  
  82.     // ----- Set to the facet's port.
  83.     
  84.     XMPWindow *xmpWindow = facet->GetXMPWindow();
  85.     WindowPtr window = xmpWindow->GetPlatformWindow();
  86.     textEdit->SetTextPort(window);
  87. //    textEdit->SetTextPort(facet->GetXMPWindow()->GetPlatformWindow());
  88.  
  89.     FW_CRect bounds;
  90.     frame->GetFrameShapeBounds(&bounds);
  91.         
  92.     // ----- Set the view rect. This is just like the view rect in TE.
  93.     
  94.     FW_SPlatformRect qdBounds;
  95.     bounds.AsPlatformRect(qdBounds);
  96.     textEdit->SetViewRect(&qdBounds);
  97.     
  98.     // ----- Set the frame size. This is similar to the dest rect in TE.
  99.     
  100.     bounds.Inset(CTextFrame::kBorderInset, CTextFrame::kBorderInset);
  101.     
  102.     LongPoint frameSize(FixedToInt(bounds.Width()), 0/*0 means unlimited hite*/);
  103.  
  104.     CFrames* frames = textEdit->GetFramesHandler();
  105.     
  106.     CDisplayChanges displayChanges;
  107.     frames->SetTextFrameSize(&frameSize, &displayChanges);
  108.  
  109.     // ------ Reflow the text if necessary.
  110.     
  111.     short action = textEdit->DisplayChanged(&displayChanges);
  112. }
  113.  
  114. //---------------------------------------------------------------------------------------------------
  115. // CTextDrawInitiator::~CTextDrawInitiator
  116. //---------------------------------------------------------------------------------------------------
  117.  
  118. CTextDrawInitiator::~CTextDrawInitiator()
  119. {
  120. }
  121.